﻿@page
@model AdminUI.Pages.STATS.UserCashModel
@{
    var F = Html.F();
}

@section body {
    <f:Panel ID="Panel1" BodyPadding="5" ShowBorder="false" Layout="VBox" ShowHeader="false" IsViewPort="true">
        <Items>
            <f:Grid ID="Grid1" BoxFlex="1" IsFluid="true" ForceFit="false" ShowBorder="true" ShowHeader="false" EnableTextSelection="true" EnableColumnLines="true" EnableCheckBoxSelect="false" EnableMultiSelect="false" AllowSorting="true" AllowPaging="true" IsDatabasePaging="true"
                    DataIDField="UserID" DataTextField="UserName" OnSort="Grid_DoAction" SortingToolTip="true" SortingCancel="true" OnPageIndexChanged="Grid_DoAction" OnRowCommand="Grid_RowCommand">
                <Toolbars>
                    <f:Toolbar ID="Toolbar1" ToolbarAlign="Right" ItemSpace="1">
                        <Items>
                            <f:Button ID="btnRefresh" IconAlign="Left" EnableDefaultState="false" IconFont="Refresh" Text="刷新" OnClientClick="__customEvent('refresh');"></f:Button>
                            <f:ToolbarFill ID="ToolbarFill1"></f:ToolbarFill>
                            <f:DropDownList ID="ddlCondition" SelectedValue="" Width="150">
                                <f:ListItem Text="== 请选择条件 ==" Value="" />
                                <f:ListItem Text="用户ID" Value="UserID" />
                                <f:ListItem Text="用户姓名" Value="TrueName" />
                                <f:ListItem Text="手机号" Value="Mobile" />
                            </f:DropDownList>
                            <f:TriggerBox ID="txtKeyword" ShowLabel="false" EmptyText="请输入搜索关键字" TriggerIcon="Search" OnTriggerClick="Grid_DoAction"></f:TriggerBox>
                        </Items>
                    </f:Toolbar>
                </Toolbars>
                <Columns>
                    <f:RowNumberField EnablePagingNumber="true" HeaderText="#" TextAlign="Center" Width="50" />
                    <f:RenderField For="List.First().UserID" QuickSortField="true" Width="150" TextAlign="Center" />
                    @* <f:RenderField For="List.First().TID" Width="80" TextAlign="Right" /> *@
                    @* <f:RenderField For="List.First().UserType" Width="100" /> *@
                    <f:RenderField For="List.First().TrueName" Width="100" />
                    <f:RenderField For="List.First().CustomerName" Width="220" />
                    <f:RenderField For="List.First().Mobile" Width="120" />
                    <f:RenderCheckField For="List.First().IsAgent" RenderAsStaticField="false" Width="80" TextAlign="Center" />
                    <f:RenderField For="List.First().Balance" Width="120" TextAlign="Right" />
                    <f:RenderField For="List.First().TotalCash" Width="120" TextAlign="Right" />
                    <f:RenderField For="List.First().TotalBonus" Width="120" TextAlign="Right" />
                </Columns>
                <Listeners>
                    <f:Listener Event="rowdblclick" Handler="onEditClick"></f:Listener>
                </Listeners>
                <PageItems>
                    <f:ToolbarSeparator></f:ToolbarSeparator>
                    <f:ToolbarText Text="每页记录数："></f:ToolbarText>
                    <f:DropDownList ID="ddlGridPageSize" Width="60" DataSource="@(new int[]{10,20,30,50,100,200})" SelectedValue="20" OnSelectedIndexChanged="Grid_DoAction"></f:DropDownList>
                </PageItems>
            </f:Grid>
        </Items>
    </f:Panel>

    <f:Window ID="Window1" IsModal="true" Hidden="true" Target="Top" EnableResize="true" EnableMaximize="true" EnableIFrame="true"
              Width="750" Height="500" OnClose="Grid_DoAction">
    </f:Window>
}

@section script {
    <script src="~/res/js/grid.js"></script>
    <script>
        function onAddClick(event) {
            var path = "/STATS/UserAdd";
            F.ui.Window1.show(path, '新增用户');
        }

        function onEditClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要修改的记录！');
                return;
            }

            var selectedRow = grid1.getSelectedRow();
            var path = "/STATS/UserEdit?id=" + selectedRow;
            F.ui.Window1.show(path, '编辑用户');
        }

        function onDeleteClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要删除的记录！');
                return;
            }

            var selectedRows = grid1.getSelectedRows();
            F.confirm({
                message: '确定要删除所选记录吗？',
                target: '_top',
                ok: function () {
                    __customEvent('grid-delete', {
                        rowIDs: selectedRows
                    });
                }
            });
        }
        function onEnableClick() {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要启用的记录！');
                return;
            }

            var selectedRows = grid1.getSelectedRows();
            F.confirm({
                message: '确定要启用所选记录吗？',
                target: '_top',
                ok: function () {
                    __customEvent('grid-enable', {
                        rowIDs: selectedRows
                    });
                }
            });
        }

        function onDisableClick() {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要禁用的记录！');
                return;
            }

            var selectedRows = grid1.getSelectedRows();
            F.confirm({
                message: '确定要禁用所选记录吗？',
                target: '_top',
                ok: function () {
                    __customEvent('grid-disable', {
                        rowIDs: selectedRows
                    });
                }
            });
        }

    </script>
}